//
//  ViewForSection1.m
//  ProjectA
//
//  Created by dllo on 16/1/20.
//  Copyright © 2016年 刘旺辉. All rights reserved.
//

#import "ViewForSection1Header.h"
#import "UIView+NightManager.h"
#import "AppMacro.h"
@interface ViewForSection1Header ()

@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UILabel *title;
@property (nonatomic, strong) UIButton *button;
@end

@implementation ViewForSection1Header
- (void)dealloc {
    
    [_label release];
    [_title release];
    [_button release];
    [super dealloc];
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        
        
        self.label = [[UILabel alloc] init];
        [self.contentView addSubview:self.label];
        [_label release];
        
        self.title = [[UILabel alloc] init];
        [self.contentView addSubview:self.title];
        [_title release];
        
        self.button = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.button];
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.label.frame = CGRectMake(10, 18, 5, self.frame.size.height - 22);
    self.label.backgroundColor = [UIColor blackColor];
    self.label.layer.cornerRadius = 3;
    self.label.layer.masksToBounds = YES;
    
    self.title.frame = CGRectMake(25, 18, self.frame.size.width / 2 - 15, self.frame.size.height - 22);
    self.title.text = @"每日精选故事";
    
    self.button.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 40, self.label.frame.origin.y + 3, 30, self.frame.size.height - 30);
    [self.button setTitle:@"全部" forState:UIControlStateNormal];
    [self.button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [UIView setColorWithLabelView:self.label nightColorWithRed:0 green:0 blue:0 alpha:1 dayColorWithRed:44 green:211 blue:209 alpha:1];
    [UIView setColorWithLabelText:self.title nightColor:L_COLOR_WHITE dayColor:L_COLOR_BLACK];
    [UIView setColorWithButton:self.button nightColor:L_COLOR_WHITE dayColor:L_COLOR_BLACK];
}


- (void)buttonAction:(UIButton *)button {
    
    
    [[NSNotificationCenter defaultCenter] postNotificationName:@"clickButton" object:nil];
}


@end
